// 内置仿函数
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
using namespace std;

// 算术仿函数
// plus minus multiplies divides modulus negate
void test1()
{
    negate<int> n1; // 取反（通过源码发现就是多了个-）
    cout << n1(13) << endl;
    cout << n1(-84) << endl;

    plus<int> p1;
    cout << p1(7, 15) << endl;
}
// 关系仿函数
// equal_to  not_equal_to greater
// greater_equal less less_equal
void test2()
{
    vector<int> v1;
    for (int i = 1; i < 6; ++i)
    {
        v1.push_back(10*i);
    }
    sort(v1.begin(), v1.end(), greater<int>());
    for (auto it = v1.begin(); it != v1.end(); ++it)
    {
        cout << *it << endl;
    }
}
// 逻辑仿函数
// logical_and logical_or logical_not
void test3()
{
    vector<bool> v1;
    for (int i = 0; i < 5; ++i)
    {
        // 偶true
        if (i % 2 == 0)
        {
            v1.push_back(true);
        }
        else
            v1.push_back(false);
    }
    vector<bool> v2;
    v2.resize(v1.size());
    transform(v1.begin(), v1.end(), v2.begin(), logical_not<bool>());
    for (auto it = v1.begin(); it != v1.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;
    for (auto it = v2.begin(); it != v2.end(); ++it)
    {
        cout << *it << " ";
    }
}
int main(void)
{
    // test1();
    // test2();
    test3();

    return 0;
}